package cn.zyl.demo.common.permanent;

import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.logging.LogManager;
import java.util.logging.Logger;

/**
 * LoggerCommon类说明: 工具类日志输出
 *
 * @author wsz
 * @version v1.0
 * @date 2020-08-04
 */
public class LoggerCommon {
    static Logger logger = Logger.getLogger("LoggerCommon");
    static LogManager logManager = LogManager.getLogManager();
    public static void main(String[] args) {
        //TODO Java原生日志工具类
        logTest();
    }
    public static void logTest(){
        try {
            //读取配制文件
            InputStream in = LoggerCommon.class.getResourceAsStream("/logging.properties");
            //注意配置
            logManager.readConfiguration(in);
            //添加Logger
            logManager.addLogger(logger);
            logger.severe("这是[severe]信息");
            logger.warning("这是[warning]信息");
            logger.info("这是[info]信息");
            logger.config("这是[config]信息");
            logger.fine("这是[fine]信息");
            logger.finer("这是[finer]信息");
            logger.finest("这是[finest]信息");
        } catch (SecurityException | IOException | ArithmeticException e) {
            e.printStackTrace();
        }
    }
}
